package io.seata.samples.nacos.storage.dubbo;

import io.seata.samples.nacos.common.dto.CommodityDTO;
import io.seata.samples.nacos.common.dubbo.StorageDubboService;
import io.seata.samples.nacos.common.response.ObjectResponse;
import io.seata.samples.nacos.storage.service.ITStorageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.seata.core.context.RootContext;

/**
 * @author Administrator
 */
@Slf4j
@RequiredArgsConstructor
@DubboService(version = "1.0.0", protocol = "${dubbo.protocol.id}", application = "${dubbo.application.id}", registry = "${dubbo.registry.id}", timeout = 3000)
public class StorageDubboServiceImpl implements StorageDubboService {
    private final ITStorageService storageService;

    @Override
    public ObjectResponse decreaseStorage(CommodityDTO commodityDTO) {
        log.info("全局事务，当前xid={}", RootContext.getXID());
        return storageService.decreaseStorage(commodityDTO);
    }
}
